using BehaviorDesigner.Runtime;
using BehaviorDesigner.Runtime.Tasks;
using UnityEngine;

//始终面向主角
public class FacePlayer : Action
{
    private float baseScaleX;
    public GameObject player;
    public override void OnAwake()
    {
        baseScaleX = transform.localScale.x;
    }

    public override TaskStatus OnUpdate()
    {
        Vector3 scale = transform.localScale;
        scale.x = transform.position.x > player.transform.position.x ? baseScaleX : -baseScaleX;
        transform.localScale = scale;
        return TaskStatus.Success;
    }
}